package com.xiaoge.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoge.annotation.ControllerEndpoint;
import com.xiaoge.entity.EduNavBar;
import com.xiaoge.response.Result;
import com.xiaoge.service.EduNavBarService;
import com.xiaoge.vo.EduNavBarVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *@作者: 冷俊杰
 *@类名: EduNavBarController类
 *@创建时间: 2022/11/10 1:10
 *@描述:
 *导航管理
 *@修改原图
 *@修改作者
 *@修改时间
 */
@Api(value = "导航管理", tags = "导航管理")
@RestController
@RequestMapping("/eduNav")
public class EduNavBarController {
    @Resource
    private EduNavBarService service;

    @ControllerEndpoint(exceptionMessage = "删除导航失败", operation = "删除导航")
    @RequiresPermissions({"eduCourse:DeEduAdv"})
    @ApiOperation(value = "删除轮播", notes = "删除导航信息，根据导航ID")
    @DeleteMapping("DeEduNav")
    public Result DeEduNav(@RequestParam(value = "id",required = true,defaultValue = "")Long id){
        service.removeById(id);
        return Result.ok();
    }

    @ControllerEndpoint(exceptionMessage = "修改导航失败", operation = "修改导航")
    @RequiresPermissions({"eduCourse:UpEduNav"})
    @ApiOperation(value = "修改导航", notes = "修改导航信息，根据导航ID")
    @PutMapping("UpEduNav")
    public Result UpEduNav(EduNavBarVO vo){
        service.UpEduNav(vo);
        return Result.ok();
    }

    @ControllerEndpoint(exceptionMessage = "添加导航失败", operation = "添加导航")
    @RequiresPermissions({"eduCourse:InEduNav"})
    @ApiOperation(value = "添加导航", notes = "添加导航信息")
    @PostMapping("InEduNav")
    public Result InEduNav(EduNavBarVO vo){
        service.InEduNav(vo);
        return Result.ok();
    }

    @ApiOperation(value = "导航列表", notes = "模糊查询导航列表")
    @PostMapping("/getEduNavList")
    public Result getEduNavList(
            @RequestParam(value = "current",required = true,defaultValue = "1") Integer current,
            @RequestParam(value = "size",required = true,defaultValue = "7") Integer size,
            @RequestParam(value = "navTitle",required = true,defaultValue = "")  String navTitle){
        Page<EduNavBar> page = new Page<>(current,size);
        Page<EduNavBar> eduNavBarByPage = service.getEduNavBarByPage(page, navTitle);
        return Result.ok().data("eduNavBarByPage",eduNavBarByPage);
    }
}
